package com.qcy.serve.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qcy.common.annotation.Log;
import com.qcy.common.core.controller.BaseController;
import com.qcy.common.core.domain.AjaxResult;
import com.qcy.common.enums.BusinessType;
import com.qcy.serve.domain.Fangju;
import com.qcy.serve.service.IFangjuService;
import com.qcy.common.utils.poi.ExcelUtil;
import com.qcy.common.core.page.TableDataInfo;

/**
 * 防具数据Controller
 * 
 * @author ruoyi
 * @date 2025-09-25
 */
@RestController
@RequestMapping("/serve/fangju")
public class FangjuController extends BaseController
{
    @Autowired
    private IFangjuService fangjuService;

    /**
     * 查询防具数据列表
     */
    @PreAuthorize("@ss.hasPermi('serve:fangju:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fangju fangju)
    {
        startPage();
        List<Fangju> list = fangjuService.selectFangjuList(fangju);
        return getDataTable(list);
    }

    /**
     * 导出防具数据列表
     */
    @PreAuthorize("@ss.hasPermi('serve:fangju:export')")
    @Log(title = "防具数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Fangju fangju)
    {
        List<Fangju> list = fangjuService.selectFangjuList(fangju);
        ExcelUtil<Fangju> util = new ExcelUtil<Fangju>(Fangju.class);
        util.exportExcel(response, list, "防具数据数据");
    }

    /**
     * 获取防具数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('serve:fangju:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fangjuService.selectFangjuById(id));
    }

    /**
     * 新增防具数据
     */
    @PreAuthorize("@ss.hasPermi('serve:fangju:add')")
    @Log(title = "防具数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fangju fangju)
    {
        return toAjax(fangjuService.insertFangju(fangju));
    }

    /**
     * 修改防具数据
     */
    @PreAuthorize("@ss.hasPermi('serve:fangju:edit')")
    @Log(title = "防具数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fangju fangju)
    {
        return toAjax(fangjuService.updateFangju(fangju));
    }

    /**
     * 删除防具数据
     */
    @PreAuthorize("@ss.hasPermi('serve:fangju:remove')")
    @Log(title = "防具数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fangjuService.deleteFangjuByIds(ids));
    }
}
